#include <iostream>
#include <cstdlib>
#include <list>

#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2

typedef int Status;
typedef int TElemType;
typedef struct BiTNode
{
	TElemType data;
	struct BiTNode *lchild, *rchild, *parent;
}BiTNode;

class BiTree
{
private:
	BiTNode *root;

public:
	BiTree();
	Status InitBiTree();
	Status DestroyBiTree();
	Status CreateBiTree(void (*func)(BiTNode *T));
	Status ClearBiTree(BiTNode *T);
	bool BiTreeEmpty();
	int BiTreeDepth(BiTNode *T, bool isroot);
	BiTNode *Root();	
	TElemType Value(BiTNode *e);
	Status Assign(BiTNode *e, TElemType value);
	BiTNode *Parent(BiTNode *e);
	BiTNode *LeftChild(BiTNode *e);
	BiTNode *RightChild(BiTNode *e);
	BiTNode *LeftSibling(BiTNode *e);
	BiTNode *RightSibling(BiTNode *e);
	Status InsertChild(BiTNode *p, int LR, BiTNode *c);
	Status DeleteChild(BiTNode *p, int LR);
	Status PreOrderTraverse(Status (*visit)(TElemType e), BiTNode *T, bool isroot);
	Status InOrderTraverse(Status (*visit)(TElemType e), BiTNode *T, bool isroot);
	Status PostOrderTraverse(Status (*visit)(TElemType e), BiTNode *T, bool isroot);
	Status LevelOrderTraverse(Status (*visit)(TElemType e));
};